import { GET_USER_INFO, TO_GENDER_ACTION, CHANGE_GENDER_MAN, CHANGE_GENDER_WOMEN, BG_DISAPPEAR } from "../types/SettingType"
const initialState = {
  userMessage: {},
  bg: '',
  iconAppear: '',
}

export default (state = initialState, { type, payload }) => {
  let newState = JSON.parse(JSON.stringify(state));
  switch (type) {

    case GET_USER_INFO:
      return { ...newState, ...payload };
    case TO_GENDER_ACTION:
      newState.bg = 'appear';
      return { ...newState, ...payload };
    case CHANGE_GENDER_MAN:
      newState.iconAppear = 'man';
      newState.bg = '';
      newState.userMessage.data.gender = 'male'
      return { ...newState, ...payload };
    case CHANGE_GENDER_WOMEN:
      newState.iconAppear = 'women';
      newState.bg = '';
      newState.userMessage.data.gender = 'female'
      return { ...newState, ...payload };
    case BG_DISAPPEAR:
      newState.bg = '';
      return { ...newState, ...payload };
    default:
      return newState
  }
}
